import { Callout, Steps, Cards, Card } from 'nextra/components';
// Path relative to the copy in the `website/` folder
import { LaravelIcon } from '../../components/icons/LaravelIcon';
import { SymfonyIcon } from '../../components/icons/SymfonyIcon';
import { NextSeo } from 'next-seo';

<NextSeo description="Getting ready to use Bref." />

# Setup

You can deploy PHP applications with Bref using either:

- [Bref Cloud](/cloud) (simplest, most features, free trial)
- or the [Serverless CLI](https://github.com/oss-serverless/serverless) (more complex, fewer features built-in, free)

Bref Cloud is the easiest way to deploy PHP applications. It simplifies setting up and managing AWS credentials, and it provides a dashboard to manage your applications, view logs, and more. Learn more about [Bref Cloud](/cloud).

This page will help you set up your environment for either option.

Before getting started, you will need PHP (8.0 or greater) and [NPM](https://nodejs.org/) installed.

## Bref Cloud

To use Bref Cloud, you will need a [Bref Cloud](/cloud) account, an AWS account, and the `bref` CLI. Let's get started:

<Steps>

    ### Bref Cloud account

    First, visit [bref.cloud](https://bref.cloud) to create an account.

    ### AWS account

    Bref Cloud deploys your applications to your AWS account.

    To create an AWS account, **go to [aws.amazon.com](https://aws.amazon.com/) and click *Sign up***. Bref Cloud will guide you through the process of creating an AWS account and connecting it to Bref Cloud.

    If you want to learn more about how Bref Cloud connects securely to your AWS account, read the ["Security" documentation](./cloud-security.mdx).

    AWS has a generous free tier that will usually allow you to deploy your first serverless applications for free.

    ### Bref CLI

    Next, let's install the Bref CLI:

    ```shell
    composer global require bref/cli
    ```

    Finally, let's connect the CLI to your Bref Cloud account:

    ```shell
    bref login
    ```

    If the `bref` command is not found, or if you want more details on how to install the CLI, read the detailed [installation instructions](./cloud-getting-started.mdx).

</Steps>

That's it, you're ready to use Bref with Bref Cloud!

<Cards num={2}>
    <Card icon={<LaravelIcon />} title="Get started with Laravel" arrow="true" href="/docs/laravel/getting-started" />
    <Card icon={<SymfonyIcon />} title="Get started with Symfony" arrow="true" href="/docs/symfony/getting-started" />
    <Card title="Get started with any PHP framework" arrow="true" href="/docs/default/getting-started" />
</Cards>

## Serverless CLI

If you don't want to use Bref Cloud, you can deploy PHP applications using the open-source [Serverless CLI](https://github.com/oss-serverless/serverless).

To use Bref with the Serverless CLI, you will need an AWS account, the `serverless` CLI, and AWS credentials. Let's get started:

<Steps>

    ### AWS account

    Bref deploys your applications to your AWS account. To create one, **go to [aws.amazon.com](https://aws.amazon.com/) and click *Sign up***.

    AWS has a generous free tier that will usually allow you to deploy your first serverless applications for free.

    ### Serverless CLI

    Bref relies on the [Serverless Framework](https://github.com/oss-serverless/serverless) and AWS access keys to deploy applications. You will need to install the `serverless` CLI using NPM:

    ```bash
    npm install -g osls
    ```

    <Callout type="info">
        The original [Serverless Framework](https://serverless.com/) is no longer open-source. An open-source alternative is [OSS Serverless](https://github.com/oss-serverless/serverless), created and maintained by Bref maintainers. This is a drop-in replacement for the original CLI and is used throughout this documentation.
    </Callout>

    ### AWS credentials

    Finally, we need AWS credentials so that the `serverless` CLI can deploy to AWS.

    <Callout type="info">
        If you have already set up AWS credentials on your machine (for example if you use the `aws` CLI), you can skip this step.
    </Callout>

    - [Create AWS access keys](./setup/aws-keys.mdx)

    - Set up those keys by running:

        ```bash
        serverless config credentials --provider aws --key "key" --secret "secret"
        ```

        This will store the credentials in `~/.aws/credentials` (the [official file for AWS credentials](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html)). This is the same as running the `aws configure` command with the `aws` CLI.

        Alternatively (for example in CI/CD), you can store credentials in environment variables:

        ```bash
        export AWS_ACCESS_KEY_ID=key
        export AWS_SECRET_ACCESS_KEY=secret
        ```

</Steps>

That's it, you're ready to use Bref with the Serverless CLI!

<Cards num={2}>
    <Card icon={<LaravelIcon />} title="Get started with Laravel" arrow="true" href="/docs/laravel/getting-started" />
    <Card icon={<SymfonyIcon />} title="Get started with Symfony" arrow="true" href="/docs/symfony/getting-started" />
    <Card title="Get started with any PHP framework" arrow="true" href="/docs/default/getting-started" />
</Cards>
